import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:jyofservice/fluro/NavigatorUtil.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class WelcomePage extends StatefulWidget {
  @override
  _WelcomePageState createState() => _WelcomePageState();
}

class _WelcomePageState extends State<WelcomePage> {

  @override
  void initState() {
    // TODO: implement initState
    Future.delayed(const Duration(seconds: 2),(){
      init().then((onValue){
        if(onValue==null) {
          NavigatorUtil.goLogin(context);

        }else{
          if(onValue == 'sfjc'){
            NavigatorUtil.goSF(context);
          } else {
            NavigatorUtil.goHome(context);
          }

        }
      });
    });
    super.initState();
  }

  Future init() async{
    SharedPreferences preferences = await SharedPreferences.getInstance();
    var basuUrl = preferences.getString("key");
    return basuUrl;
  }

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      body: Container(
        width: ScreenUtil().screenWidth,
        height: ScreenUtil().screenHeight,
        child: Image.asset("images/welcome_page.png",fit: BoxFit.fill,),
      ),
    );
  }
}
